home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / RELEASE.ZIP / sub_arctic / test / frame_test.java < prev    next >
Encoding:
Java Source  |  1996-10-04  |  3.0 KB  |  103 lines

  1. package sub_arctic.test;
  2.  
  3. import sub_arctic.input.*;
  4. import sub_arctic.lib.*;
  5. import sub_arctic.output.*;
  6. import sub_arctic.constraints.std_function;
  7.  
  8. public class frame_test extends interactor_applet implements callback_object 
  9. {
  10.   button show_button;
  11.   button hide_button;
  12.   interactor_frame iframe;
  13.  
  14.   /**
  15.    * This is the build_ui method for the APPLET
  16.    */
  17.   public void build_ui(base_parent_interactor top) {
  18.     /* put a button in */
  19.     show_button=new button(0,0,"Push Me", this);
  20.     top.add_child(show_button);
  21.     /* center the button */
  22.     top.child(0).set_x_constraint(std_function.centered(PARENT.X2(), 0));
  23.     top.child(0).set_y_constraint(std_function.centered(PARENT.Y2(), 0));
  24.   }
  25.   /**
  26.    * This gets called if we get uniconified, so we need to put the
  27.    * frame back on the screen.
  28.    */
  29.   public void start() {
  30.     if (iframe!=null) {
  31.       iframe.show();
  32.     }
  33.   }
  34.   /**
  35.    * You get a call to stop if the browser gets iconified.  We take
  36.    * the window off the screen.
  37.    */
  38.   public void stop() {
  39.     if (iframe!=null) {
  40.       iframe.hide();
  41.     }
  42.   }
  43.   /**
  44.    * Create the extra frame.
  45.    */
  46.   public void newFrame() {
  47.     /* if we already have a frame, don't need another one */
  48.     if (iframe!=null) {
  49.       return;
  50.     }
  51.     /* make a new toplevel... the size will get overriden with
  52.      * constraints  */
  53.     top_level tl=new top_level();
  54.     /* put the button at 10, 10 and use 10 and 10 as the border sizes */
  55.     hide_button=new button(10,10,"Push Me Too!", this);
  56.     tl.add_child(hide_button);
  57.     /* set constraints on the tl size .. we add the constants to
  58.        compensate for AWT brain damage */
  59.     tl.set_h_constraint(std_function.offset(MAX_CHILD.Y2(), 35));
  60.     tl.set_w_constraint(std_function.offset(MAX_CHILD.X2(), 25));
  61.     iframe=new interactor_frame("Test Frame", tl);
  62.     /* if you called "setResizable() on iframe here you could force it
  63.      * to never get bigger */
  64.     iframe.set_callback_obj(this);
  65.     iframe.show();
  66.   }
  67.   /**
  68.    * Called when they press the button 
  69.    */
  70.   public void callback(interactor from_obj, event evt, int callback_num, 
  71.                Object callback_info) {
  72.     /* figure out who sent this */
  73.     if (from_obj==show_button) {
  74.       newFrame();
  75.     } else {
  76.       /* is it the user hitting the hide button? */
  77.       if (from_obj==hide_button) {
  78.     iframe.hide();
  79.     iframe=null;
  80.       } else {
  81.     /* must be the top level telling use the user killed us */
  82.     iframe=null;
  83.       }
  84.     }
  85.   }
  86. }
  87. /*=========================== COPYRIGHT NOTICE ===========================
  88.  
  89. This file is part of the subArctic user interface toolkit.
  90.  
  91. Copyright (c) 1996 Scott Hudson and Ian Smith
  92. All rights reserved.
  93.  
  94. The subArctic system is freely available for most uses under the terms
  95. and conditions described in 
  96.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  97. and appearing in full in the lib/interactor.java source file.
  98.  
  99. The current release and additional information about this software can be 
  100. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  101.  
  102. ========================================================================*/
  103.